# encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')

class FT_078e:
    result=[]
    #2,2，5，0
    analysisDecription = ['自定义消息体长度：','数据项个数：','CAN总线数据接收时间：','CAN总线数据项']
    #4，2，1，n
    can_data=['CAN ID:','CAN数据长度','CAN数据']

    def LogicAisle(self, protocolStr, header):
        msglen=protocolStr[0:4]
        header.append(self.analysisDecription[0]+msglen+'\n')
        data_num=int(protocolStr[4:8],16)
        header.append(self.analysisDecription[1]+str(data_num)+'\n')
        cantime=protocolStr[8:18]
        header.append(self.analysisDecription[2]+cantime[0:2]+'-'+cantime[2:4]+'-'+cantime[4:6]+'-'+cantime[6:8]+'-'+cantime[8:10]+'-'+cantime[10:12]+'\n')
        s=protocolStr[18:]
        for i in range(data_num):
            canid=s[0:8]
            canlen=int(s[8:10],16)
            canval=s[10:10+canlen*2]
            header.append(self.can_data[0]+canid+'\n')
            header.append(self.can_data[1] + str(canlen) + '\n')
            header.append(self.can_data[2] + canval + '\n')
            s=s[10+canlen*2]
        self.result=header
